<?php

namespace App\Models;

class Report extends Model
{
    protected $fillable = ['type','comment','edit_type'];

    protected $table = 'report';

    protected $OpenType=[1=>'个人',2=>'企业'];
    protected $Type=[1=>'审核通过',2=>'申报中', 3=>'申报驳回', 4=>'申报失败'];
    protected $RegisterType=[1=>'正常',2=>'注销'];
    protected $EditType=[1=>'正常',2=>'变更中'];

    public function getOpenTypeAttribute($value)
    {
        return isset($this->OpenType[$value]) ? $this->OpenType[$value] : reset($this->OpenType);
    }

    public function getTypeAttribute($value)
    {
        return isset($this->Type[$value]) ? $this->Type[$value] : reset($this->Type);
    }
    public function getRegisterTypeAttribute($value)
    {
        return isset($this->RegisterType[$value]) ? $this->RegisterType[$value] : reset($this->RegisterType);
    }
    public function getEditTypeAttribute($value)
    {
        return isset($this->EditType[$value]) ? $this->EditType[$value] : reset($this->EditType);
    }

    public function postsUser()
    {
        return $this->hasMany(ReportUser::class);
    }

    public function reporteditlog()
    {
        return $this->hasMany(ReportEditLog::class,'report_id','id')->orders('created_at desc');
    }




}
